class AutoBindComponent extends HelperComponent {
    onLoad(node) {
        if (!node.node) {
            return;
        }
        Object.defineProperty(node,'ab',{
            value : this
        });
        this.autoBind(node);
    }

    autoBind(node) {
        if (this[node.name]) {
            var type = typeof this[node.name];
            if (type != 'array') {
                var temp = this[node.name];
                this[node.name] = [];
                this[node.name].push(temp);
            }
            this[node.name].push(node);
        }
        else {
            this[node.name] = node;
        }
        if (node.children.length) {
            for (var i = 0; i < node.children.length; i++) {
                this.autoBind(node.children[i]);
            }
        }
    }
}
